function c = nancorr(x1,x2)
  
%%%% This function computes the correlation between two vectors x1 and x2, but excludes missing values.


 z = x1 + x2;
 i = find(isnan(z)==0);
 c = NaN;
 
 if isempty(i)==0
 c = corr(x1(i),x2(i));
 end
 
end

